package com.headfirst.StructuralMode.decorator.version1.condiment;

import com.headfirst.StructuralMode.decorator.myutils.Calculate;
import com.headfirst.StructuralMode.decorator.version1.Beverage;
import com.headfirst.StructuralMode.decorator.version1.CondimentDecorator;

/**
 * 豆浆（是一种具体的调味品类，继承了抽象的调味品类CondimentDecorator）
 * 也可以看成是具体的装饰者类，或称装饰者对象，可以用来装饰具体的饮料，比如HouseBlend、Espresso、Decaf和DarkRoast等
 *
 * @author sunhongguang
 * @create 2022-01-22-21:21
 */
public class Soy extends CondimentDecorator {
    private Beverage beverage;

    public Soy(Beverage beverage) {
        this.beverage = beverage;
        super.setSize(beverage.getSize());
    }

    @Override
    public String getDescription() {
        return beverage.getDescription() + ", Soy";
    }

    @Override
    public double cost() {
        double price = 0;
        switch (super.getSize()) {
            case "小杯":
                price = 0.10;
                break;
            case "中杯":
                price = 0.15;
                break;
            case "大杯":
                price = 0.20;
                break;
            case "超大杯":
                price = 0.25;
                break;
        }
        return Calculate.getDoubleResult(price, beverage.cost());
    }
}
